import router from '@/router/index'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import session from '@/utils/session'

NProgress.configure({ showSpinner: false })

const whiteList = ['/login', '/auth-redirect']

router.beforeEach(async (to, from, next) => {
  NProgress.start()
  if (to.path !== '/login' &&!session.getToken('token')) {
    next('/login');
    NProgress.done();
  } else next()
})

router.afterEach(() => {
  NProgress.done()
})
